<template>
  <window-content class="instance-window" v-if="store" :gutter="10">
    <window-content-col>
      <span>选择副本</span>
      <div class="scrollbar-row">
        <cg-scrollbar wrap-height="max">
          <div class="gird-content">
            <cg-gird :column="{ gutter: 10, colNum: 1 }">
              <cg-gird-item v-for="item in store.instances" :key="'' + item.id"
                :class="{ 'is-active': selected === item.id }" @click="handleSelected(item.id)">
                <cg-image :path="item.head_path"></cg-image>
                <div class="gird-title">{{ item.name }}</div>
              </cg-gird-item>
            </cg-gird>
          </div>
        </cg-scrollbar>
      </div>
    </window-content-col>
    <window-content-col>
      <span>进入副本</span>
      <div :style="{ paddingTop: '20vh' }">
        <cg-button @click="startGame">开始游戏</cg-button>
      </div>
    </window-content-col>
  </window-content>
</template>

<script setup lang="ts">
import { ref, onMounted, inject, type Ref } from 'vue'
import SceneStore from '../sceneStore'
import windowContent from './content.vue'
import windowContentCol from './contentCol.vue'

const store: Ref<SceneStore> | undefined = inject('store')

const gameEvents: any | undefined = inject('gameEvents')

onMounted(() => { })

const selected = ref(undefined)

const handleSelected = (value: any) => {
  selected.value = value
}

const startGame = () => {
  if (gameEvents) {
    gameEvents.gameStartBattle()
  }
}

</script>

<style lang="scss">
.instance-window {}
</style>
